/**
 * #[User.java] 	version:1.0	15-12-2013
 */
package cl.cesarg.agenda.model.dao;

import org.springframework.stereotype.Component;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;

import cl.cesarg.agenda.model.entities.UserEntity;

/**
 * @author 	Cesar Gonzalez		cesar@cesarg.cl		http://twitter.com/donpandix
 * @version	1.0 15-12-2013
 *
 */
@Component
public class UserDao implements IUserDao {

	/* (non-Javadoc)
	 * @see cl.cesarg.agenda.model.dao.IUser#startUpApplication()
	 */
	@Override
	public void startUpApplication( UserEntity userEntity ) {
		
		DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
		
		Entity usuario = new Entity(UserEntity.class.getSimpleName(), userEntity.getEmail());
		usuario.setProperty("email", userEntity.getEmail());
		usuario.setProperty("name", userEntity.getName());
		usuario.setProperty("password", userEntity.getPassword());
		usuario.setProperty("suName", userEntity.getSuName());
		usuario.setProperty("userName", userEntity.getUserName());
		
		datastore.put(usuario);

	}

}
